//
//  AlbumTag.swift
//  hello
//
//  Created by 赵康 on 2024/11/11.
//

import Fluent
import Vapor

final class AlbumTag: Model, Content, @unchecked Sendable {
	static var schema: String { SchemaEnum.albumTags.rawValue }
	
	@ID(key: .id)
	var id: UUID?
	
	@Parent(key: FieldKeys.album)
	var album: Album
	
	@Parent(key: FieldKeys.tag)
	var tag: Tag
	
	@OptionalField(key: FieldKeys.isDeleted)
	var isDeleted: Bool?
	
	@Timestamp(key: FieldKeys.createdAt, on: .create)
	var createdAt: Date?
	
	@Timestamp(key: FieldKeys.updatedAt, on: .update)
	var updatedAt: Date?
	
	init() { }
	
	init(id: UUID? = nil, albumID: Album.IDValue, tagID: Tag.IDValue, isDeleted: Bool?, createdAt: Date?, updatedAt: Date?) {
		self.id = id
		self.$album.id = albumID
		self.$tag.id = tagID
		self.isDeleted = isDeleted
		self.createdAt = createdAt
		self.updatedAt = updatedAt
	}
}
